 <?php
					
include 'conn.php';		

$request_body = file_get_contents('php://input');
$data = json_decode($request_body, true);

if($_GET['lx']=='GetListData'){


	
}elseif($_GET['lx']=='getSelect'){
	
	$zd=$data['zd'];
	$sql="SELECT ".$zd." as label,".$zd." as value,COUNT(*) as num  FROM ".$data['table']." GROUP BY ".$zd." ORDER BY num desc";
	$rows = array();
	$rs =  mysqli_query($con,$sql);
	while($row = $rs->fetch_assoc()){
		array_push($rows,$row);
	} 

	$result["code"] = 200;
	$result["data"] = $rows;
	$result["message"] = $sql;
	echo json_encode($result);

}elseif($_GET['lx']=='del'){

	$sql="DELETE FROM ".$data['table']." WHERE id=".$data['id'];
	mysqli_query($con,$sql);
	
	$result["code"] = 200;
	$result["message"] = "删除成功！";
	$result['sql']=$sql;
	echo json_encode($result);	


}else{

	$result["code"] = 201;
	$result["message"] = "201";
	echo json_encode($result);
	
}


?>